<template>
  <sv-page>
    <!-- 列表 -->
    <view class="cu-list menu sm-border sv-cu-list">
      <view
        class="cu-item arrow"
        v-for="item in buyLibData"
        :key="item.lib_id"
        @click="onLib(item)"
      >
        <view class="content">
          <text class="cuIcon-circlefill text-grey"></text>
          <text class="text-cyan">{{ item.lib_name }}</text>
        </view>
      </view>
    </view>
  </sv-page>
</template>

<script setup>
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { store } from '@/uni_modules/sv-id-pages/common/store'
import { buyLibList } from '@/service/api/record'

const buyLibData = ref([])

onLoad(async () => {
  uni.showLoading({ title: '加载中' })
  const buyLibRes = await buyLibList({ user_id: store.userInfo._id })
  buyLibData.value = buyLibRes.data || []
  uni.hideLoading()
})

function onLib(item) {
  uni.navigateTo({
    url: `/pages/lib/lib?lib_id=${item.lib_id}`
  })
}
</script>

<style></style>
